#ifndef CRTP_HPP
#define CRTP_HPP

template <template <typename> class Derived>
class Base {
	static size_t count;
public:
	Base(){count++;}
	Base(const Base & rhs){count++;}
	~Base(){count--;}

	static size_t live() {return count;}
};

template <template <typename> class Derived>
size_t Base<Derived>::count = 0;

template<typename T>
class Derived : public Base<Derived> {
public:
	size_t typesize(){return sizeof(T);}
};

template <typename Derived2>
class Base2 {
	static size_t count;
public:
	Base2(){count++;}
	Base2(const Base2 & rhs){count++;}
	~Base2(){count--;}

	static size_t live() {return count;}
};

template <typename Derived2>
size_t Base2<Derived2>::count = 0;

template<typename T>
class Derived2 : public Base2<Derived2<T> > {
public:
	size_t typesize(){return sizeof(T);}
};

#endif